class Solution
{
public:
    int maxBottlesDrunk(int numBottles, int numExchange)
    {
        int result = 0;
        while (numBottles >= numExchange)
        {
            numBottles -= numExchange;
            result += numExchange;
            numBottles += 1;
            numExchange += 1;
        }
        result += numBottles;
        return result;
    }
};